#pragma once

#include <string>
#include <unordered_map>
#include <vector>
#include "cocos2d.h"
#include "XYLib/xy_wdf.h"
#include "XYLib/xy_was.h"

using animate_sequene = std::vector<cocos2d::Animate*>;
struct WFile {
	XY_Wdf::WdfFileHeader		info;
	XY_Wdf*						handle;
};
using WASFile = std::unordered_map<uint32_t, WFile>;
class ResManager
{
protected:
	ResManager();
	~ResManager();
public:
	static ResManager*	GetInstance(void);
	static void	Release(void);

	void			SetResPath(const char* path);
	const char*		GetResPath(void) const;

	bool			AddWdfRes(const char* fileName);

	XY_Wdf::WdfFile	GetWDFFile(uint32_t uid);

public:
	cocos2d::Texture2D*				GetTexture(uint32_t uid, bool cache = false, const std::vector<XY_Was::Wpal>* wpal = nullptr);
	cocos2d::Animate*				GetAnimate(uint32_t uid, float delay, const std::vector<XY_Was::Wpal>* wpal = nullptr);
	animate_sequene					GetAnimateSequene(uint32_t uid, float delay, bool& err, const std::vector<XY_Was::Wpal>* wpal = nullptr);
private:
	static ResManager*	__instance;
	std::string			_filePath;
	WASFile				_wasFile;
};